


<?
	  layout("/inc/win_layout.html",{title:sysTitle}){
    ?>
<div class="col-lg-4">
	<div class="panel" style="height: 380px; overflow: auto;">
		<div class="panel-heading">字典项管理</div>
			
		<div class="panel-body">
			<ul id="tree" class="ztree" style="width:300px"; overflow:auto;">
				
			</ul>
		</div>
		
	</div>
</div>
<?} ?>
<script>
function getQueryString(name) { 
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	var r = window.location.search.substr(1).match(reg); 
	if (r != null) return unescape(r[2]); return null; 
	} 
	var winName=getQueryString("winName");

	var dictId = window.parent.window[winName].getmultiDictId();
	var multiId = window.parent.window[winName].getmultiId();			//所属 Id
	//树状结构
	$(function() {
		initTree();
	});
	function initTree() {
		$.ajax({
			type : "post",
			data : {
				"dictId" : dictId
			},
			url : "findallDictItemZTree.do",
			dataType : "json",
			beforeSend : function(XMLHttpRequest) {
			},
			success : drawTree,
		});
	}
	var setting = {
		check: {
			enable: true,
			nocheckInherit: true,
			chkboxType: {"Y" : "", "N" : ""}
		},
		view: {
			dblClickExpand: false
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
		}
	};
	function drawTree(data) {
		var zNodes = eval(data);
		$.fn.zTree.init($("#tree"), setting, zNodes).expandAll(true);
		zTree = $.fn.zTree.getZTreeObj("tree");
		zTree.expandNode(zTree.getNodes()[0], true);//指定某节点折叠

	}
	
	
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	
	
	function queren(){
			var treeObj = $.fn.zTree.getZTreeObj("tree");
			var checkedNode = treeObj.getCheckedNodes(); 
			var menuids="";
			var menuNames="";
			for(var i=0;i<checkedNode.length;i++){
				if(checkedNode[i].id!=null){
					menuids+=checkedNode[i].value+",";
					menuNames+=checkedNode[i].name+",";
				}
			}
			//menuids=menuids.substring(0,menuids.length-1);
			menuNames=menuNames.substring(0,menuNames.length-1);
		if(menuids==''){
			alert("请选择您想添加的字典！");
			
		}else{
			window.parent.window[winName].$("#dictitemId_"+multiId).val(menuids);
		    window.parent.window[winName].$("#dictitemName_"+multiId).val(menuNames);
		   	parent.layer.tips("Ok", "#t_"+multiId, {time: 5000});
			parent.layer.close(index);
		}
	}
	
	
</script>



